﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AdministracionCooperativa.Controlador;

namespace AdministracionCooperativa
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //VALIDAMOS LA CONTASEÑA EN BD SI ESCORRECTA ENTRAMOS
            var idUser = ControladorUsuario.ExisteUsuario(textBox1.Text,textBox2.Text);
            if (idUser > 0)
            {
                //HABILITAR PANTALLAS
                this.Visible = false;
                Form3 menu = new Form3();
                Form4 banner = new Form4();
                banner.idusuario = idUser;
                menu.MdiParent = this.MdiParent;
                banner.MdiParent = this.MdiParent;
                menu.Show();
                banner.Show();
            }
            else 
            {
                MessageBox.Show("Usuario NO encontrado");
            }
        }

        

        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == Convert.ToChar(13))
            {
                button1_Click(sender, e);
             }
        }

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == Convert.ToChar(13))
            {
                textBox2.Focus();
            }
        }
    }
}
